From 3056d793a40d20574fa95cd6a4f6cc619b724039 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Feb 2016 04:19:42 +0100 Subject: [PATCH] cssparser: Make _gtk_css_parser_has_number() a bit smarter Previously we just checked the first character. And if that was a "-" as in "-gtk-some-special-value", we assumed it was a number. Which it clearly wasn't. Test included --- gtk/gtkcssparser.c | 9 ++++++++- testsuite/css/parser/Makefile.am | 2 ++ .../css/parser/background-win32-color-is-no-error.css | 3 +++ .../parser/background-win32-color-is-no-error.ref.css | 9 +++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 testsuite/css/parser/background-win32-color-is-no-error.css create mode 100644 testsuite/css/parser/background-win32-color-is-no-error.ref.css diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c index 86320f3a72..44ff7bcfca 100644 --- a/gtk/gtkcssparser.c +++ b/gtk/gtkcssparser.c @@ -599,8 +599,15 @@ _gtk_css_parser_try_double (GtkCssParser *parser, gboolean _gtk_css_parser_has_number (GtkCssParser *parser) { + char c; + + if (parser->data[0] == '-' || parser->data[0] == '+') + c = parser->data[1]; + else + c = parser->data[0]; + /* ahem */ - return strchr ("+-0123456789.", parser->data[0]) != NULL; + return g_ascii_isdigit (c) || c == '.'; } GtkCssValue * diff --git a/testsuite/css/parser/Makefile.am b/testsuite/css/parser/Makefile.am index 54c9506a5f..d7744764cc 100644 --- a/testsuite/css/parser/Makefile.am +++ b/testsuite/css/parser/Makefile.am @@ -195,6 +195,8 @@ test_data = \ background-shorthand-single.ref.css \ background-size.css \ background-size.ref.css \ + background-win32-color-is-no-error.css \ + background-win32-color-is-no-error.ref.css \ border.css \ border.errors \ border.ref.css \ diff --git a/testsuite/css/parser/background-win32-color-is-no-error.css b/testsuite/css/parser/background-win32-color-is-no-error.css new file mode 100644 index 0000000000..3b17e20c02 --- /dev/null +++ b/testsuite/css/parser/background-win32-color-is-no-error.css @@ -0,0 +1,3 @@ +a { + background: -gtk-win32-color(edit, highlight); +} diff --git a/testsuite/css/parser/background-win32-color-is-no-error.ref.css b/testsuite/css/parser/background-win32-color-is-no-error.ref.css new file mode 100644 index 0000000000..7879519a91 --- /dev/null +++ b/testsuite/css/parser/background-win32-color-is-no-error.ref.css @@ -0,0 +1,9 @@ +a { + background-clip: border-box; + background-color: -gtk-win32-color(edit, highlight); + background-image: none; + background-origin: padding-box; + background-position: left top; + background-repeat: repeat; + background-size: auto; +} -- 2.30.2